package com.example.harmonyos04_01.slice;

import com.example.harmonyos04_01.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 该slice所对应的界面配置文件
        super.setUIContent(ResourceTable.Layout_ability_main);
        
        //  获取按钮01
        Button button_01 = (Button) this.findComponentById(ResourceTable.Id_button_01);

        // 设置按钮的单击事件
        button_01.setClickedListener(this::ClickedListenerButton01);
        
        
    }

    private void ClickedListenerButton01(Component component) {
        // 同一个Ability里  页面之间的跳转
        Intent intent = new Intent();
        this.present(new MainAbilitySlice02(),intent);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
